<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateMatchDataTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::dropIfExists('match_data');

		Schema::create('match_data', function(Blueprint $table)
		{
			$table->engine = 'InnoDB';

			$table->increments('id');

			$table->dateTime('date', 255);
			$table->string('comments', 255);
			$table->unsignedInteger('fieldId');
			$table->unsignedInteger('matchTypeId');
			$table->unsignedInteger('admin_userId');
			$table->timestamps();
		});

		Schema::table('match_data', function($table)
		{
		    $table->foreign('fieldId')->references('id')->on('field')->onDelete('cascade');
			$table->foreign('matchTypeId')->references('id')->on('match_type')->onDelete('cascade');
			$table->foreign('admin_userId')->references('id')->on('user')->onDelete('cascade');
		});
	}

	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		Schema::dropIfExists('match-data');
	}

}
